<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
          "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<title>QUnit for ASN1 Encoder Class 'asn1cades.js'</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="qunit.js"></script>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />

<script src="../ext/cj/cryptojs-312-core-fix.js"></script>
<script src="../ext/cj/x64-core.js"></script>
<script src="../ext/cj/cipher-core_min.js"></script>
<script src="../ext/cj/aes_min.js"></script>
<script src="../ext/cj/tripledes_min.js"></script>
<script src="../ext/cj/enc-base64_min.js"></script>
<script src="../ext/cj/md5_min.js"></script>
<script src="../ext/cj/sha1_min.js"></script>
<script src="../ext/cj/sha256_min.js"></script>
<script src="../ext/cj/sha224_min.js"></script>
<script src="../ext/cj/sha512_min.js"></script>
<script src="../ext/cj/sha384_min.js"></script>
<script src="../ext/cj/ripemd160_min.js"></script>
<script src="../ext/cj/hmac_min.js"></script>
<script src="../ext/cj/pbkdf2_min.js"></script>


<script src="../ext/jsbn.js"></script>
<script src="../ext/jsbn2.js"></script>
<script src="../ext/prng4.js"></script>
<script src="../ext/rng.js"></script>
<script src="../ext/rsa.js"></script>
<script src="../ext/rsa2.js"></script>
<script src="../ext/base64.js"></script>
<script src="../src/base64x-1.1.js"></script>
<script src="../src/asn1hex-1.1.js"></script>
<script src="../src/rsapem-1.1.js"></script>
<script src="../src/rsasign-1.2.js"></script>
<script src="../src/crypto-1.1.js"></script>
<script src="../src/keyutil-1.0.js"></script>
<script src="../src/asn1-1.0.js"></script>
<script src="../src/asn1x509-1.0.js"></script>
<script src="../src/asn1cms-1.0.js"></script>
<script src="../src/asn1cades-1.0.js"></script>
<script src="../src/x509-1.1.js"></script>

<script type="text/javascript">
<!--
$(document).ready(function(){

// _test/z4.* RSA 2048bit
var sZ4_CERPEM = (function() {/*
-----BEGIN CERTIFICATE-----
MIIC/zCCAeegAwIBAgIBATANBgkqhkiG9w0BAQUFADAaMQswCQYDVQQGEwJVUzEL
MAkGA1UECgwCWjQwHhcNMTMwODI4MTgyODM0WhcNMjMwODI4MTgyODM0WjAaMQsw
CQYDVQQGEwJVUzELMAkGA1UECgwCWjQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
ggEKAoIBAQDfdOqotHd55SYO0dLz2oXengw/tZ+q3ZmOPeVmMuOMIYO/Cv1wk2U0
OK4pug4OBSJPhl09Zs6IwB8NwPOU7EDTgMOcQUYB/6QNCI1J7Zm2oLtuchzz4pIb
+o4ZAhVprLhRyvqi8OTKQ7kfGfs5Tuwmn1M/0fQkfzMxADpjOKNgf0uy6lN6utjd
TrPKKFUQNdc6/Ty8EeTnQEwUlsT2LAXCfEKxTn5RlRljDztS7Sfgs8VL0FPy1Qi8
B+dFcgRYKFrcpsVaZ1lBmXKsXDRu5QR/Rg3f9DRq4GR1sNH8RLY9uApMl2SNz+sR
4zRPG85R/se5Q06Gu0BUQ3UPm67ETVZLAgMBAAGjUDBOMB0GA1UdDgQWBBQHZPTE
yQVu/0I/3QWhlTyW7WoTzTAfBgNVHSMEGDAWgBQHZPTEyQVu/0I/3QWhlTyW7WoT
zTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQDHxqJ9y8alTH7agVMW
Zfic/RbrdvHwyq+IOrgDToqyo0w+IZ6BCn9vjv5iuhqu4ForOWDAFpQKZW0DLBJE
Qy/7/0+9pk2DPhK1XzdOovlSrkRt+GcEpGnUXnzACXDBbO0+Wrk+hcjEkQRRK1bW
2rknARIEJG9GS+pShP9Bq/0BmNsMepdNcBa0z3a5B0fzFyCQoUlX6RTqxRw1h1Qt
5F00pfsp7SjXVIvYcewHaNASbto1n5hrSz1VY9hLba11ivL1N4WoWbmzAL6BWabs
C2D/MenST2/X6hTKyGXpg3Eg2h3iLvUtwcNny0hRKstc73Jl9xR3qXfXKJH0ThTl
q0gq
-----END CERTIFICATE-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

// from qunit-do-asn1cms (19) CMSUtil.newSignedData/3 2+signcertv2,sigpol added
var z4sig1 = "3082059006092a864886f70d010702a08205813082057d020101310f300d06096086480165030402010500301806092a864886f70d010701a00b04096a737273617369676ea0820303308202ff308201e7a003020102020101300d06092a864886f70d0101050500301a310b3009060355040613025553310b3009060355040a0c025a34301e170d3133303832383138323833345a170d3233303832383138323833345a301a310b3009060355040613025553310b3009060355040a0c025a3430820122300d06092a864886f70d01010105000382010f003082010a0282010100df74eaa8b47779e5260ed1d2f3da85de9e0c3fb59faadd998e3de56632e38c2183bf0afd7093653438ae29ba0e0e05224f865d3d66ce88c01f0dc0f394ec40d380c39c414601ffa40d088d49ed99b6a0bb6e721cf3e2921bfa8e19021569acb851cafaa2f0e4ca43b91f19fb394eec269f533fd1f4247f3331003a6338a3607f4bb2ea537abad8dd4eb3ca28551035d73afd3cbc11e4e7404c1496c4f62c05c27c42b14e7e519519630f3b52ed27e0b3c54bd053f2d508bc07e745720458285adca6c55a6759419972ac5c346ee5047f460ddff4346ae06475b0d1fc44b63db80a4c97648dcfeb11e3344f1bce51fec7b9434e86bb405443750f9baec44d564b0203010001a350304e301d0603551d0e041604140764f4c4c9056eff423fdd05a1953c96ed6a13cd301f0603551d230418301680140764f4c4c9056eff423fdd05a1953c96ed6a13cd300c0603551d13040530030101ff300d06092a864886f70d01010505000382010100c7c6a27dcbc6a54c7eda81531665f89cfd16eb76f1f0caaf883ab8034e8ab2a34c3e219e810a7f6f8efe62ba1aaee05a2b3960c016940a656d032c1244432ffbff4fbda64d833e12b55f374ea2f952ae446df86704a469d45e7cc00970c16ced3e5ab93e85c8c49104512b56d6dab927011204246f464bea5284ff41abfd0198db0c7a974d7016b4cf76b90747f3172090a14957e914eac51c3587542de45d34a5fb29ed28d7548bd871ec0768d0126eda359f986b4b3d5563d84b6dad758af2f53785a859b9b300be8159a6ec0b60ff31e9d24f6fd7ea14cac865e9837120da1de22ef52dc1c367cb48512acb5cef7265f71477a977d72891f44e14e5ab482a3182024430820240020101301f301a310b3009060355040613025553310b3009060355040a0c025a34020101300d06096086480165030402010500a081f7301806092a864886f70d010903310b06092a864886f70d010701301c06092a864886f70d010905310f170d3133313233313233353935395a302e060b2a864886f70d010910020f311f301d06042a0304053015300906052b0e03021a05000408b1b2b3b4b5b6b7b8302f06092a864886f70d0109043122042084c24dd1d9f56eb3a07ae4a23445add4facbaed78c89475296ab7954284d9cd4305c060b2a864886f70d010910022f314d304b304930470420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e944423023301ea41c301a310b3009060355040613025553310b3009060355040a0c025a34020101300d06092a864886f70d01010b05000482010013c73a7f055ba1e242d300fc9ceae61a6fa56ceea05b5ae2fc2b4508812cecbf07a09ce4670622f58aa89d4465a705dad2c2e284651d0c5add679257ac8f656a661e8dc902c21cab8cb9886333bf427839ce56a3cd71284731e8da566aa543ad2d932a96ff9087775e4f6e2b0f04c7d4d9e8b921c2fe024ba0c9efa8279703e4a3c9baaeb1c9a5f9e10672a81d058b64a81208f5e88fe8b038e648d65a0474283d0660c46fb7636d085abc2d0e39f74e8ad50a9bb233fa43adddf852d23dd79bd0819b68225d3ee5ecfb0eb2a54c4af859d1bdc350443221db5189a5a8b9c92766dae014ec6badb0abcf2e806c071c6a9f7e3f651f39eda28dc5e509516cb359";

// ----- OtherCertID ---------------

test("OtherCertID for CompleteCertificateRefs", function() {
var _OtherCertID = KJUR.asn1.cades.OtherCertID;

var hExpect = "3016041476c19d787741bdaf76cab1c42d166cb536aa83f8";
var o = new _OtherCertID(sZ4_CERPEM);
equal(o.getEncodedHex(), hExpect, "hex certPEM");
equal(
ASN1HEX.dump(o.getEncodedHex()),
ASN1HEX.dump(hExpect),
"hex certPEM");

var hExpect2 = "30583031300d060960864801650304020105000420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e944423023301ea41c301a310b3009060355040613025553310b3009060355040a0c025a34020101";
var params2 = {cert: sZ4_CERPEM, alg: "sha256", hasis: true}
var o2 = new _OtherCertID(params2);
equal(o2.getEncodedHex(), hExpect2, "hex cert/alg=sha256/hasis=true");
equal(
ASN1HEX.dump(o2.getEncodedHex()),
ASN1HEX.dump(hExpect2),
"dump cert/alg=sha256/hasis=true");

var hExpect3 = "30333031300d060960864801650304020105000420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e94442";
var params3 = {cert: sZ4_CERPEM, alg: "sha256", hasis:false};
var o3 = new _OtherCertID(params3);
equal(o3.getEncodedHex(), hExpect3, "hex cert/alg=sha256/hasis=false");
equal(
ASN1HEX.dump(o3.getEncodedHex()),
ASN1HEX.dump(hExpect3),
"dump cert/alg=sha256/hasis=false");

var hExpect4 = "303a3013300d060960864801650304020305000402abcd3023301ea41c301a310b3009060355040613024a50310b3009060355040a0c025431020107";
var params4 = {hash: "abcd", alg: "sha512", issuer: {str: "/C=JP/O=T1"}, serial: {hex: "07"}};
var o4 = new _OtherCertID(params4);
equal(o4.getEncodedHex(), hExpect4, "hex hash/alg=sha256/issuer/serial");
equal(
ASN1HEX.dump(o4.getEncodedHex()),
ASN1HEX.dump(hExpect4),
"dump hash/alg=sha256/issuer/serial");
});

// ----- OtherHashAlg ---------------

test("OtherHash for CompleteCertificateRefs", function() {
var o = new KJUR.asn1.cades.OtherHash("1234");
equal(o.getEncodedHex(), "04021234", "str 1234");

var o2 = new KJUR.asn1.cades.OtherHash({alg: 'sha256', hash: '1234'});
equal(o2.getEncodedHex(), "3013300d0609608648016503040201050004021234", "{alg:sha256,hash:1234}");

var o3 = new KJUR.asn1.cades.OtherHash(sZ4_CERPEM); // OtherHashValue(sha1) default
equal(o3.getEncodedHex(), "041476c19d787741bdaf76cab1c42d166cb536aa83f8", "certPEM");

var o4 = new KJUR.asn1.cades.OtherHash({alg: 'sha256', cert: sZ4_CERPEM});
equal(o4.getEncodedHex(), "3031300d060960864801650304020105000420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e94442", "{alg:sha256,cert:pem}");

var o5 = new KJUR.asn1.cades.OtherHash({cert: sZ4_CERPEM}); // OtherHashValue(sha1) default
equal(o5.getEncodedHex(), "041476c19d787741bdaf76cab1c42d166cb536aa83f8", "{cert:pem} OtherHashValue(sha1)");

var o6 = new KJUR.asn1.cades.OtherHash({alg: 'sha1', cert: sZ4_CERPEM});
equal(o6.getEncodedHex(), "3021300906052b0e03021a0500041476c19d787741bdaf76cab1c42d166cb536aa83f8", "{alg:sha1,cert:pem}");
});

// ----- OtherHashAlgAndValue ---------------

test("OtherHashAlgAndValue for CompleteCertificateRefs test", function() {
var _OtherHashAlgAndValue = KJUR.asn1.cades.OtherHashAlgAndValue;

var hExpect = "300f300906052b0e03021a0500040212ab";
var params = {alg: "sha1", hash: "12ab"};
equal((new _OtherHashAlgAndValue(params)).getEncodedHex(), hExpect, "hash hex");
equal(
ASN1HEX.dump((new _OtherHashAlgAndValue(params)).getEncodedHex()),
ASN1HEX.dump(hExpect),
"hash dump");

var hExpect2 = "3021300906052b0e03021a0500041476c19d787741bdaf76cab1c42d166cb536aa83f8";
var params2 = {alg: "sha1", cert: sZ4_CERPEM};
equal((new _OtherHashAlgAndValue(params2)).getEncodedHex(), hExpect2, "cert pem hex");
equal(
ASN1HEX.dump((new _OtherHashAlgAndValue(params2)).getEncodedHex()),
ASN1HEX.dump(hExpect2),
"cert pem dump");

var hExpect3 = "3021300906052b0e03021a0500041476c19d787741bdaf76cab1c42d166cb536aa83f8"; // =hExpect2
var params3 = {alg: "sha1", cert: pemtohex(sZ4_CERPEM)};
equal((new _OtherHashAlgAndValue(params3)).getEncodedHex(), hExpect3, "cert hex hex");
equal(
ASN1HEX.dump((new _OtherHashAlgAndValue(params3)).getEncodedHex()),
ASN1HEX.dump(hExpect3),
"cert hex dump");
});

test("OtherHashValue for CompleteCertificateRefs test", function() {
var _OtherHashValue = KJUR.asn1.cades.OtherHashValue;
equal((new _OtherHashValue({hash: "12ab"})).getEncodedHex(), "040212ab", "hash");
equal((new _OtherHashValue({cert: sZ4_CERPEM})).getEncodedHex(), "041476c19d787741bdaf76cab1c42d166cb536aa83f8", "cert pem");
equal((new _OtherHashValue({cert: pemtohex(sZ4_CERPEM)})).getEncodedHex(), "041476c19d787741bdaf76cab1c42d166cb536aa83f8", "cert pem");
});

test("attr CompleteCertificateRefs", function() {
var _CompleteCertificateRefs = KJUR.asn1.cades.CompleteCertificateRefs;

var hExpect = "3059060b2a864886f70d0109100215314a30483016041476c19d787741bdaf76cab1c42d166cb536aa83f83016041476c19d787741bdaf76cab1c42d166cb536aa83f83016041476c19d787741bdaf76cab1c42d166cb536aa83f8";
var params = {array: [sZ4_CERPEM,sZ4_CERPEM,sZ4_CERPEM]};
var o = new _CompleteCertificateRefs(params);
equal(o.getEncodedHex(), hExpect, "hex array=[certz4,certz4,certz4]");
equal(
ASN1HEX.dump(o.getEncodedHex()),
ASN1HEX.dump(hExpect),
"dump array=[certz4,certz4,certz4]");

var hExpect = "30820123060b2a864886f70d0109100215318201123082010e30583031300d060960864801650304020105000420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e944423023301ea41c301a310b3009060355040613025553310b3009060355040a0c025a3402010130583031300d060960864801650304020105000420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e944423023301ea41c301a310b3009060355040613025553310b3009060355040a0c025a3402010130583031300d060960864801650304020105000420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e944423023301ea41c301a310b3009060355040613025553310b3009060355040a0c025a34020101";
var params = {array: [
  {cert:sZ4_CERPEM,alg:"sha256",hasis:true},
  {cert:sZ4_CERPEM,alg:"sha256",hasis:true},
  {cert:sZ4_CERPEM,alg:"sha256",hasis:true}
]};
var o = new _CompleteCertificateRefs(params);
equal(o.getEncodedHex(), hExpect, "hex array=[{cert/sha256/hasis},{cert/sha256/hasis},{cert/sha256/hasis}]");
equal(
ASN1HEX.dump(o.getEncodedHex()),
ASN1HEX.dump(hExpect),
"dump array=[{cert/sha256/hasis},{cert/sha256/hasis},{cert/sha256/hasis}]");

var hExpect = "30820123060b2a864886f70d0109100215318201123082010e30583031300d060960864801650304020105000420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e944423023301ea41c301a310b3009060355040613025553310b3009060355040a0c025a3402010130583031300d060960864801650304020105000420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e944423023301ea41c301a310b3009060355040613025553310b3009060355040a0c025a3402010130583031300d060960864801650304020105000420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e944423023301ea41c301a310b3009060355040613025553310b3009060355040a0c025a34020101";
var params = {
  array: [sZ4_CERPEM,sZ4_CERPEM,sZ4_CERPEM],
  alg: "sha256",
  hasis: true
};
var o = new _CompleteCertificateRefs(params);
equal(o.getEncodedHex(), hExpect, "hex array=[{cert/sha256/hasis},{cert/sha256/hasis}]");
equal(
ASN1HEX.dump(o.getEncodedHex()),
ASN1HEX.dump(hExpect),
"dump array=[{cert/sha256/hasis},{cert/sha256/hasis}]");

});

test("attr SignaturePolicyIdentifier", function() {
var o = new KJUR.asn1.cades.SignaturePolicyIdentifier({
  oid: '1.2.3.4.5',
  alg: 'sha1',
  hash: 'a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0'
});
equal(o.getEncodedHex(), "303a060b2a864886f70d010910020f312b302906042a0304053021300906052b0e03021a05000414a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0", "");
});

test("attr SignatureTimeStamp", function() {
var hExpect = "3014060b2a864886f70d010910020e31053003010101";
var o = new KJUR.asn1.cades.SignatureTimeStamp({
  tst: '3003010101'
});
equal(o.getEncodedHex(), hExpect, "hex1");
equal(
ASN1HEX.dump(o.getEncodedHex()),
ASN1HEX.dump(hExpect),
"dump1");
});

test("CAdESUtil.parseSignedDataForAddingUnsigned z4sig1", function() {
var pResult = KJUR.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned(z4sig1);

var pExpect = {
  version: 1,
  hashalgs: ["sha256"],
  econtent: {
    type: "data",
    content: {hex: "6a737273617369676e"},
  },
  certs: {
    array: [
"-----BEGIN CERTIFICATE-----\r\n"+
"MIIC/zCCAeegAwIBAgIBATANBgkqhkiG9w0BAQUFADAaMQswCQYDVQQGEwJVUzEL\r\n"+
"MAkGA1UECgwCWjQwHhcNMTMwODI4MTgyODM0WhcNMjMwODI4MTgyODM0WjAaMQsw\r\n"+
"CQYDVQQGEwJVUzELMAkGA1UECgwCWjQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw\r\n"+
"ggEKAoIBAQDfdOqotHd55SYO0dLz2oXengw/tZ+q3ZmOPeVmMuOMIYO/Cv1wk2U0\r\n"+
"OK4pug4OBSJPhl09Zs6IwB8NwPOU7EDTgMOcQUYB/6QNCI1J7Zm2oLtuchzz4pIb\r\n"+
"+o4ZAhVprLhRyvqi8OTKQ7kfGfs5Tuwmn1M/0fQkfzMxADpjOKNgf0uy6lN6utjd\r\n"+
"TrPKKFUQNdc6/Ty8EeTnQEwUlsT2LAXCfEKxTn5RlRljDztS7Sfgs8VL0FPy1Qi8\r\n"+
"B+dFcgRYKFrcpsVaZ1lBmXKsXDRu5QR/Rg3f9DRq4GR1sNH8RLY9uApMl2SNz+sR\r\n"+
"4zRPG85R/se5Q06Gu0BUQ3UPm67ETVZLAgMBAAGjUDBOMB0GA1UdDgQWBBQHZPTE\r\n"+
"yQVu/0I/3QWhlTyW7WoTzTAfBgNVHSMEGDAWgBQHZPTEyQVu/0I/3QWhlTyW7WoT\r\n"+
"zTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQDHxqJ9y8alTH7agVMW\r\n"+
"Zfic/RbrdvHwyq+IOrgDToqyo0w+IZ6BCn9vjv5iuhqu4ForOWDAFpQKZW0DLBJE\r\n"+
"Qy/7/0+9pk2DPhK1XzdOovlSrkRt+GcEpGnUXnzACXDBbO0+Wrk+hcjEkQRRK1bW\r\n"+
"2rknARIEJG9GS+pShP9Bq/0BmNsMepdNcBa0z3a5B0fzFyCQoUlX6RTqxRw1h1Qt\r\n"+
"5F00pfsp7SjXVIvYcewHaNASbto1n5hrSz1VY9hLba11ivL1N4WoWbmzAL6BWabs\r\n"+
"C2D/MenST2/X6hTKyGXpg3Eg2h3iLvUtwcNny0hRKstc73Jl9xR3qXfXKJH0ThTl\r\n"+
"q0gq\r\n"+
"-----END CERTIFICATE-----\r\n"
    ],
    sortflag: false
  },
  sinfos: [{
    version: 1,
    id: {
      type:'isssn',
      issuer: {
        array: [
          [{type:"C",value:"US",ds:"prn"}],
          [{type:"O",value:"Z4",ds:"utf8"}]
        ],
        str: "/C=US/O=Z4"
      },
      serial: {hex: "01"}
    },
    hashalg: "sha256",
    sattrs: {array: [{
      attr: "contentType",
      type: "data"
    },{
      attr: "signingTime",
      str: '131231235959Z'
    },{
      attr: "signaturePolicyIdentifier",
      oid: "1.2.3.4.5",
      alg: "sha1",
      hash: "b1b2b3b4b5b6b7b8"
    },{
      attr: "messageDigest",
      hex: '84c24dd1d9f56eb3a07ae4a23445add4facbaed78c89475296ab7954284d9cd4'
    },{
      attr: "signingCertificateV2",
      array: [{
        alg: "sha256",
        hash: "c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e94442",
        issuer: {
          array: [
            [{type:"C", value:"US", ds:"prn"}],
            [{type:"O", value:"Z4", ds:"utf8"}]
          ],
          str: "/C=US/O=Z4"
        },
        serial: {hex: "01"}
      }]
    }]},
    sigalg: "SHA256withRSA",
    sighex: "13c73a7f055ba1e242d300fc9ceae61a6fa56ceea05b5ae2fc2b4508812cecbf07a09ce4670622f58aa89d4465a705dad2c2e284651d0c5add679257ac8f656a661e8dc902c21cab8cb9886333bf427839ce56a3cd71284731e8da566aa543ad2d932a96ff9087775e4f6e2b0f04c7d4d9e8b921c2fe024ba0c9efa8279703e4a3c9baaeb1c9a5f9e10672a81d058b64a81208f5e88fe8b038e648d65a0474283d0660c46fb7636d085abc2d0e39f74e8ad50a9bb233fa43adddf852d23dd79bd0819b68225d3ee5ecfb0eb2a54c4af859d1bdc350443221db5189a5a8b9c92766dae014ec6badb0abcf2e806c071c6a9f7e3f651f39eda28dc5e509516cb359"
  }]
};
deepEqual(pResult, pExpect, "z4sig1 parsed");
});

test("CAdESUtil.parseSignedDataForAddingUnsigned z4sig1 + SigTS", function() {
  var tstHex = "308205a106092a864886f70d010702a08205923082058e020101310f300d060960864801650304020105003075060b2a864886f70d0109100104a0660464306202010106042a0304053015300d060960864801650304020105000404a1a2a3a4020103181332303133313233313233353935392e3132335a3004800201f40101ff020103301c310b3009060355040613025553310d300b060355040a0c0454535031a082031530820311308201f9a00302010202014d300d06092a864886f70d0101050500301b310b3009060355040613025553310c300a060355040a0c03434131301e170d3133303530313233353935395a170d3233303530313233353935395a301c310b3009060355040613025553310d300b06035504030c045453413130820122300d06092a864886f70d01010105000382010f003082010a0282010100df74eaa8b47779e5260ed1d2f3da85de9e0c3fb59faadd998e3de56632e38c2183bf0afd7093653438ae29ba0e0e05224f865d3d66ce88c01f0dc0f394ec40d380c39c414601ffa40d088d49ed99b6a0bb6e721cf3e2921bfa8e19021569acb851cafaa2f0e4ca43b91f19fb394eec269f533fd1f4247f3331003a6338a3607f4bb2ea537abad8dd4eb3ca28551035d73afd3cbc11e4e7404c1496c4f62c05c27c42b14e7e519519630f3b52ed27e0b3c54bd053f2d508bc07e745720458285adca6c55a6759419972ac5c346ee5047f460ddff4346ae06475b0d1fc44b63db80a4c97648dcfeb11e3344f1bce51fec7b9434e86bb405443750f9baec44d564b0203010001a35f305d300c0603551d130101ff04023000300b0603551d0f0404030206c030160603551d250101ff040c300a06082b0601050507030830280603551d1f0421301f301da01ba0198617687474703a2f2f746573742e636f6d2f6361312e63726c300d06092a864886f70d010105050003820101004d926e469e2162dcf2aa6da7c254df26a475898c5dacb424535717930885d40badd80f95ca0011b33c7f98d91f1f0ab39af1c1a51e61573a52727bf9675de66874fcb1254bc02a8853a7ab06fab25521df08488d88a368b9045f1a087766f2a77c1347c9bc1b9daa411cdba21aead15203f8045b47df86c0a437f9575008eebc32eab53b54ef3054e9d225875d8fc327fec7a02c61272203dcd60ba384e7dd0af09af6cf8bbce5b88ceef896bcf7993cd1d234cd5f7bef3029b3fceb826d2e3fd5ae095cb1700b6946a5ca1d87b3b80f4338f2bacd5fca11163cedd3e8a31c04c5e36fa6a7c4be6af583b9ab1d612536372f585a84170c4c02d0c9312216fd52318201e6308201e20201013020301b310b3009060355040613025553310c300a060355040a0c0343413102014d300d06096086480165030402010500a08198301806092a864886f70d010903310b06092a864886f70d010701302f06092a864886f70d010904312204206a406164d3957a11066a3d880b463102691f476c91832eb8f2cb75642db3fb53304b060b2a864886f70d010910020c313c303a3038041439c9062cec9d6c9f2a54326729032a5843054f9e3020301b310b3009060355040613025553310c300a060355040a0c0343413102014d300d06092a864886f70d01010b05000482010005c4435c8c50d370e83b58963b2bbb603daabd0c88ba11d6b529b6052093da7d10010553ef4d6b583ec6c7ac9226c038dfa78fc8dccc9e1456ee514ffb56bf21f108b9ed8538f4b55fef4bf63049a4cf158cec1c4b83c14060201fbeec23d78eee31e13d2fcfe56b1d51c7729f7e410e355ba755c87a71db24b40d69e40baecc7316e240e708e9ab3203097b50385b6f928bd4bd37fc4b15bb30587cd91c459d77030733243245f3df3e51641e8493e23c92f90c683202f7ffee0bdfe8931204c15c777117bde9964fb4102c839b379eaae13215f54c4d5e83c9d9edec9afea6a54ee1531fb1c6fdaf55a1407998d136745d87b137e2d16c57c1acf2600bdadd";

var hExpect = "30820b4e06092a864886f70d010702a0820b3f30820b3b020101310f300d06096086480165030402010500301806092a864886f70d010701a00b04096a737273617369676ea0820303308202ff308201e7a003020102020101300d06092a864886f70d0101050500301a310b3009060355040613025553310b3009060355040a0c025a34301e170d3133303832383138323833345a170d3233303832383138323833345a301a310b3009060355040613025553310b3009060355040a0c025a3430820122300d06092a864886f70d01010105000382010f003082010a0282010100df74eaa8b47779e5260ed1d2f3da85de9e0c3fb59faadd998e3de56632e38c2183bf0afd7093653438ae29ba0e0e05224f865d3d66ce88c01f0dc0f394ec40d380c39c414601ffa40d088d49ed99b6a0bb6e721cf3e2921bfa8e19021569acb851cafaa2f0e4ca43b91f19fb394eec269f533fd1f4247f3331003a6338a3607f4bb2ea537abad8dd4eb3ca28551035d73afd3cbc11e4e7404c1496c4f62c05c27c42b14e7e519519630f3b52ed27e0b3c54bd053f2d508bc07e745720458285adca6c55a6759419972ac5c346ee5047f460ddff4346ae06475b0d1fc44b63db80a4c97648dcfeb11e3344f1bce51fec7b9434e86bb405443750f9baec44d564b0203010001a350304e301d0603551d0e041604140764f4c4c9056eff423fdd05a1953c96ed6a13cd301f0603551d230418301680140764f4c4c9056eff423fdd05a1953c96ed6a13cd300c0603551d13040530030101ff300d06092a864886f70d01010505000382010100c7c6a27dcbc6a54c7eda81531665f89cfd16eb76f1f0caaf883ab8034e8ab2a34c3e219e810a7f6f8efe62ba1aaee05a2b3960c016940a656d032c1244432ffbff4fbda64d833e12b55f374ea2f952ae446df86704a469d45e7cc00970c16ced3e5ab93e85c8c49104512b56d6dab927011204246f464bea5284ff41abfd0198db0c7a974d7016b4cf76b90747f3172090a14957e914eac51c3587542de45d34a5fb29ed28d7548bd871ec0768d0126eda359f986b4b3d5563d84b6dad758af2f53785a859b9b300be8159a6ec0b60ff31e9d24f6fd7ea14cac865e9837120da1de22ef52dc1c367cb48512acb5cef7265f71477a977d72891f44e14e5ab482a31820802308207fe020101301f301a310b3009060355040613025553310b3009060355040a0c025a34020101300d06096086480165030402010500a081f7301806092a864886f70d010903310b06092a864886f70d010701301c06092a864886f70d010905310f170d3133313233313233353935395a302e060b2a864886f70d010910020f311f301d06042a0304053015300906052b0e03021a05000408b1b2b3b4b5b6b7b8302f06092a864886f70d0109043122042084c24dd1d9f56eb3a07ae4a23445add4facbaed78c89475296ab7954284d9cd4305c060b2a864886f70d010910022f314d304b304930470420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e944423023301ea41c301a310b3009060355040613025553310b3009060355040a0c025a34020101300d06092a864886f70d01010b05000482010013c73a7f055ba1e242d300fc9ceae61a6fa56ceea05b5ae2fc2b4508812cecbf07a09ce4670622f58aa89d4465a705dad2c2e284651d0c5add679257ac8f656a661e8dc902c21cab8cb9886333bf427839ce56a3cd71284731e8da566aa543ad2d932a96ff9087775e4f6e2b0f04c7d4d9e8b921c2fe024ba0c9efa8279703e4a3c9baaeb1c9a5f9e10672a81d058b64a81208f5e88fe8b038e648d65a0474283d0660c46fb7636d085abc2d0e39f74e8ad50a9bb233fa43adddf852d23dd79bd0819b68225d3ee5ecfb0eb2a54c4af859d1bdc350443221db5189a5a8b9c92766dae014ec6badb0abcf2e806c071c6a9f7e3f651f39eda28dc5e509516cb359a18205ba308205b6060b2a864886f70d010910020e318205a5308205a106092a864886f70d010702a08205923082058e020101310f300d060960864801650304020105003075060b2a864886f70d0109100104a0660464306202010106042a0304053015300d060960864801650304020105000404a1a2a3a4020103181332303133313233313233353935392e3132335a3004800201f40101ff020103301c310b3009060355040613025553310d300b060355040a0c0454535031a082031530820311308201f9a00302010202014d300d06092a864886f70d0101050500301b310b3009060355040613025553310c300a060355040a0c03434131301e170d3133303530313233353935395a170d3233303530313233353935395a301c310b3009060355040613025553310d300b06035504030c045453413130820122300d06092a864886f70d01010105000382010f003082010a0282010100df74eaa8b47779e5260ed1d2f3da85de9e0c3fb59faadd998e3de56632e38c2183bf0afd7093653438ae29ba0e0e05224f865d3d66ce88c01f0dc0f394ec40d380c39c414601ffa40d088d49ed99b6a0bb6e721cf3e2921bfa8e19021569acb851cafaa2f0e4ca43b91f19fb394eec269f533fd1f4247f3331003a6338a3607f4bb2ea537abad8dd4eb3ca28551035d73afd3cbc11e4e7404c1496c4f62c05c27c42b14e7e519519630f3b52ed27e0b3c54bd053f2d508bc07e745720458285adca6c55a6759419972ac5c346ee5047f460ddff4346ae06475b0d1fc44b63db80a4c97648dcfeb11e3344f1bce51fec7b9434e86bb405443750f9baec44d564b0203010001a35f305d300c0603551d130101ff04023000300b0603551d0f0404030206c030160603551d250101ff040c300a06082b0601050507030830280603551d1f0421301f301da01ba0198617687474703a2f2f746573742e636f6d2f6361312e63726c300d06092a864886f70d010105050003820101004d926e469e2162dcf2aa6da7c254df26a475898c5dacb424535717930885d40badd80f95ca0011b33c7f98d91f1f0ab39af1c1a51e61573a52727bf9675de66874fcb1254bc02a8853a7ab06fab25521df08488d88a368b9045f1a087766f2a77c1347c9bc1b9daa411cdba21aead15203f8045b47df86c0a437f9575008eebc32eab53b54ef3054e9d225875d8fc327fec7a02c61272203dcd60ba384e7dd0af09af6cf8bbce5b88ceef896bcf7993cd1d234cd5f7bef3029b3fceb826d2e3fd5ae095cb1700b6946a5ca1d87b3b80f4338f2bacd5fca11163cedd3e8a31c04c5e36fa6a7c4be6af583b9ab1d612536372f585a84170c4c02d0c9312216fd52318201e6308201e20201013020301b310b3009060355040613025553310c300a060355040a0c0343413102014d300d06096086480165030402010500a08198301806092a864886f70d010903310b06092a864886f70d010701302f06092a864886f70d010904312204206a406164d3957a11066a3d880b463102691f476c91832eb8f2cb75642db3fb53304b060b2a864886f70d010910020c313c303a3038041439c9062cec9d6c9f2a54326729032a5843054f9e3020301b310b3009060355040613025553310c300a060355040a0c0343413102014d300d06092a864886f70d01010b05000482010005c4435c8c50d370e83b58963b2bbb603daabd0c88ba11d6b529b6052093da7d10010553ef4d6b583ec6c7ac9226c038dfa78fc8dccc9e1456ee514ffb56bf21f108b9ed8538f4b55fef4bf63049a4cf158cec1c4b83c14060201fbeec23d78eee31e13d2fcfe56b1d51c7729f7e410e355ba755c87a71db24b40d69e40baecc7316e240e708e9ab3203097b50385b6f928bd4bd37fc4b15bb30587cd91c459d77030733243245f3df3e51641e8493e23c92f90c683202f7ffee0bdfe8931204c15c777117bde9964fb4102c839b379eaae13215f54c4d5e83c9d9edec9afea6a54ee1531fb1c6fdaf55a1407998d136745d87b137e2d16c57c1acf2600bdadd";

var _SignedData = KJUR.asn1.cms.SignedData;
var pBES = KJUR.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned(z4sig1);
pBES.sinfos[0].uattrs = {array: [{attr: "signatureTimeStamp", tst: tstHex}]};
var hEST = (new _SignedData(pBES)).getContentInfoEncodedHex();
equal(hEST, hExpect, "hex1");
equal(
ASN1HEX.dump(hEST),
ASN1HEX.dump(hExpect),
"dump1");
});

});
-->
</script>
  
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">test markup</div>
<div>
<a href="index.html">TEST INDEX</a> |
<a href="../api/index.html">APIDOCS</a> | 
<a href="qunit-do-asn1.html">asn1</a> | 
<a href="qunit-do-asn1x509.html">asn1x509</a> | 
<a href="qunit-do-asn1cms.html">asn1cms</a> | 
<a href="qunit-do-asn1tsp.html">asn1tsp</a> | 
</div>
</body>
</html>

